package com.remote.common.context;

import com.remote.common.RemoteFactory;
import com.remote.common.context.listener.CloseListener;
import com.remote.common.context.listener.ConnectListener;
import com.remote.common.context.listener.ReadListener;
import com.remote.common.exception.RemoteException;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

import java.util.List;

public interface RemoteContext {
    /**
     * 新增连接监听
     *
     * @param connectListener
     */
    void addConnectListener(ConnectListener connectListener);

    /**
     * 新增关闭监听
     *
     * @param closeListener
     */
    void addCloseListener(CloseListener closeListener);

    /**
     * 新增读取监听
     *
     * @param readListener
     */
    void addReadListener(ReadListener<?> readListener);

    /**
     * 设置通道初始化器
     *
     * @param channelInitializer
     */
    void setChannelInitializer(ChannelInitializer<SocketChannel> channelInitializer);

    /**
     * 连接
     *
     * @throws RemoteException
     */
    Channel connect() throws RemoteException;

    /**
     * 关闭
     */
    void close();

    /**
     * 刷新
     */
    void refresh();

    /**
     * 获取工厂
     *
     * @return
     */
    RemoteFactory getRemoteFactory();

    /**
     * 获取所有关闭监听
     *
     * @return
     */
    List<CloseListener> getCloseListeners();

    /**
     * 获取所有读取监听
     *
     * @return
     */
    List<ReadListener> getReadListeners();

    /**
     * 获取所有连接监听
     *
     * @return
     */
    List<ConnectListener> getConnectListeners();
}
